import time
import sys


# Get ServerId
omsserver=AdminConfig.list("Server","server1.*")
print "Set the jvm system properties and memory settings on omsserver"
jvm=AdminConfig.list('JavaVirtualMachine',omsserver)
omsjvmparams="-Dvendor=shell -DvendorFile=<%=@yfs_local%>/properties/servers.properties"
AdminConfig.modify(jvm, [['genericJvmArguments', omsjvmparams]])
AdminConfig.modify(jvm, '[[maximumHeapSize 2048]]')
AdminConfig.modify(jvm, '[[initialHeapSize 2048]]')


print "Configure Websphere log files"

#JVM Logs
outlog = AdminConfig.showAttribute(omsserver, 'outputStreamRedirect')
errlog = AdminConfig.showAttribute(omsserver, 'errorStreamRedirect')
AdminConfig.modify(outlog, '[[rolloverSize 20] [maxNumberOfBackupFiles 20]]')
AdminConfig.modify(errlog,'[[rolloverSize 20] [maxNumberOfBackupFiles 20]]')
#Trace Log
trclog = AdminConfig.list('TraceLog',omsserver)
AdminConfig.modify(trclog, '[[rolloverSize 20] [maxNumberOfBackupFiles 20]]')

print "Saving changes"
AdminConfig.save()
# Sleep is here because the save needs to happen completely before we stop/start the server...
time.sleep(60)
print "Done saving changes"



